import redis
import logging


class Config(object):
    DEBUG = True
    SECRET_KEY = "cbyugifchjhjacsbl"

    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information14"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True #当数据库操作完成自动提交


    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

#     设置session配置信息
    SESSION_TYPE = 'redis'# 保存类型
    SESSION_USE_SIGNER = True# 签名存储
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    PERMANENT_SESSION_LIFETIME = 3600*24*2# 设置存储时间为两天，单位 秒

    #设置默认日志等级
    LEVEL = logging.DEBUG

#开发环境配置信息
class DevelopConfig(Config):
    pass

#生产环境配置信息
class ProductConfig(Config):
    DEBUG = False
    LEVEL = logging.ERROR

#测试环境配置
class TestingConfig(Config):
    TESTING = True

# 通过字典统一访问配置类
config_dict = {
    "develop": DevelopConfig,
    "product": ProductConfig,
    "testing": TestingConfig
}